<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../../../favicon.ico">

    <title>Dashboard Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" href="../../../../dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="dashboard.css" rel="stylesheet" th:href="@{/assets/css/dashboard.css}">
  </head>

  <body>
    <!--引入抽取的topbar-->
    <!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
    <div th:replace="commons/bar :: topbar">
    </div>

    <div class="container-fluid">
      <div class="row">
        <!--映入侧边栏-->
        <div th:replace="commons/bar :: #sidebar(activeUri = 'emps')">
        </div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">

          <h2><a th:href="@{/emp}" class="btn btn-sm btn-success">员工添加</a></h2>
          <div class="table-responsive">
            <table class="table table-striped table-sm">
              <thead>
                <tr>
                  <th>#</th>
                  <th>lastName</th>
                  <th>email</th>
                  <th>gender</th>
                  <th>department</th>
                  <th>birth</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <tr th:each="emp:${emps}">
                  <td th:text="${emp.id}">1,001</td>
                  <td>[[${emp.lastName}]]</td>
                  <td th:text="${emp.email}">1,001</td>
                  <td th:text="${emp.gender} == 0 ? '女' : '男'">1,001</td>
                  <td th:text="${emp.department.departmentName}">1,001</td>
                  <td th:text="${#dates.format(emp.birth, 'yyyy-MM-dd HH:mm')}">1,001</td>
                  <td>
                    <a th:href="@{/emp/} + ${emp.id}" class="btn btn-sm btn-primary">编辑</a>
                    <button th:attr="del_url=@{/emp/}+${emp.id}" class="btn btn-sm btn-danger delete">删除</button>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </main>
        <form id="deleteForm" method="post">
          <input type="hidden" name="_method" value="delete"/>
        </form>
      </div>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script th:src="@{/webjars/jquery/3.4.1/jquery.slim.min.js}" src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script>window.jQuery || document.write('<script  src="[[@{/webjars/jquery/3.4.1/jquery.slim.min.js}]]"><\/script>')</script>
    <script th:src="@{/webjars/popper.js/1.15.0/popper.min.js}" src="../../../../assets/js/vendor/popper.min.js"></script>
    <script th:src="@{/webjars/bootstrap/4.3.1/js/bootstrap.js}" src="../../../../dist/js/bootstrap.min.js"></script>

    <!-- Icons -->
    <script th:src="@{/assets/js/feather.min.js}" src="https://unpkg.com/feather-icons/dist/feather.min.js"></script>
    <script>
      feather.replace()
    </script>

    <!-- Graphs -->
    <script th:src="@{/webjars/Chart.js/2.5.0/dist/Chart.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
    <script>
      $('.delete').click(function () {
        $('#deleteForm').attr('action', $(this).attr('del_url')).submit();
      });
      var ctx = document.getElementById("myChart");
      var myChart = new Chart(ctx, {
        type: 'line',
        data: {
          labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
          datasets: [{
            data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
            lineTension: 0,
            backgroundColor: 'transparent',
            borderColor: '#007bff',
            borderWidth: 4,
            pointBackgroundColor: '#007bff'
          }]
        },
        options: {
          scales: {
            yAxes: [{
              ticks: {
                beginAtZero: false
              }
            }]
          },
          legend: {
            display: false,
          }
        }
      });
    </script>
  </body>
</html>
